#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, k;
ll a[N], b[N];
ll c[N];
bool check(int x) {
  rep(i, 1, n) c[i] = a[i] * 1000 - b[i] * x;
  sort(c + 1, c + n + 1);
  ll sum = accumulate(c + k + 1, c + n + 1, 0ll);
  return sum >= 0;
}
void solve() {
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) cin >> b[i];
  int l = 1, r = 1000;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << (r + 5) / 10 << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n >> k && n) solve();

  return 0;
}